package Model;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 *
 * @author kiko
 */
public class AtendeServer extends Thread {
    ServerSocket welcomeServer;
    ServerList<Socket> serverList = new ServerList();
    
    public AtendeServer(ServerSocket welcomeServer, ServerList<Socket> serverList) {
        this.welcomeServer = welcomeServer;
        this.serverList = serverList;
    }

    @Override
    public void run() {
        try {
            while (true) {
                final Socket aux = welcomeServer.accept();
                serverList.adicione(aux);
                System.out.println ("Server received connection from " + aux.getInetAddress());
            }
        } catch (IOException ex) {
            System.out.println("Erro ao receber conexao");
        }
    }
}
